from rest_framework.fields import SerializerMethodField
from rest_framework.serializers import ModelSerializer

from course.models import TeacherModel, CourseModel


class TeacherSer(ModelSerializer):
    class Meta:
        model=TeacherModel
        fields='__all__'

class CourseSer(ModelSerializer):
    tea=SerializerMethodField()
    def get_tea(self,obj):
        return {'name':obj.teacher.name,'job':obj.teacher.job,'headimg':obj.teacher.headimg,'intro':obj.teacher.intro}
    class Meta:
        model=CourseModel
        fields='__all__'